package com.ruoyi.report_lqhhl.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report_lqhhl.domain.vo.ReportLqhhlDwddbgBsInfoVo;
import com.ruoyi.report_lqhhl.domain.bo.ReportLqhhlDwddbgBsInfoBo;
import com.ruoyi.report_lqhhl.service.IReportLqhhlDwddbgBsInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 沥青混合料动稳定度试验检测报告
 *
 * @author llb
 * @date 2024-08-19
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report_lqhhl/lqhhlDwddbgBsInfo")
public class ReportLqhhlDwddbgBsInfoController extends BaseController {

    private final IReportLqhhlDwddbgBsInfoService iReportLqhhlDwddbgBsInfoService;

    /**
     * 查询沥青混合料动稳定度试验检测报告列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<ReportLqhhlDwddbgBsInfoVo> list(ReportLqhhlDwddbgBsInfoBo bo, PageQuery pageQuery) {
        return iReportLqhhlDwddbgBsInfoService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出沥青混合料动稳定度试验检测报告列表
     */
    @SaCheckLogin
    @Log(title = "沥青混合料动稳定度试验检测报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ReportLqhhlDwddbgBsInfoBo bo, HttpServletResponse response) {
        List<ReportLqhhlDwddbgBsInfoVo> list = iReportLqhhlDwddbgBsInfoService.queryList(bo);
        ExcelUtil.exportExcel(list, "沥青混合料动稳定度试验检测报告", ReportLqhhlDwddbgBsInfoVo.class, response);
    }

    /**
     * 获取沥青混合料动稳定度试验检测报告详细信息
     *
     * @param excelId 主键
     */
    @SaCheckLogin
    @GetMapping("/{excelId}")
    public R<ReportLqhhlDwddbgBsInfoVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long excelId) {
        return R.ok(iReportLqhhlDwddbgBsInfoService.queryById(excelId));
    }

    /**
     * 新增沥青混合料动稳定度试验检测报告
     */
    @SaCheckLogin
    @Log(title = "沥青混合料动稳定度试验检测报告", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ReportLqhhlDwddbgBsInfoBo bo) {
        return toAjax(iReportLqhhlDwddbgBsInfoService.insertByBo(bo));
    }

    /**
     * 修改沥青混合料动稳定度试验检测报告
     */
    @SaCheckLogin
    @Log(title = "沥青混合料动稳定度试验检测报告", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ReportLqhhlDwddbgBsInfoBo bo) {
        return toAjax(iReportLqhhlDwddbgBsInfoService.updateByBo(bo));
    }

    /**
     * 删除沥青混合料动稳定度试验检测报告
     *
     * @param excelIds 主键串
     */
    @SaCheckLogin
    @Log(title = "沥青混合料动稳定度试验检测报告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{excelIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] excelIds) {
        return toAjax(iReportLqhhlDwddbgBsInfoService.deleteWithValidByIds(Arrays.asList(excelIds), true));
    }

    /**
     * 检测结论
     */
    @SaCheckLogin
    @Log(title = "生成  报告 检测结论", businessType = BusinessType.OTHER)
    @PutMapping("/jcjl")
    public R<ReportLqhhlDwddbgBsInfoVo> jcjl(@RequestBody ReportLqhhlDwddbgBsInfoVo vo) {
        return R.ok(iReportLqhhlDwddbgBsInfoService.jcjl(vo));
    }
}
